﻿Public Class CreateWorkshopA
    Inherits System.Web.UI.Page

    Private Shared prevPage As String = String.Empty

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If (Not IsPostBack) Then
            prevPage = Request.UrlReferrer.ToString()
        End If
    End Sub

    Protected Sub createButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles createButton.Click

        'set the values from teh text boxes to SQL variables
        Dim id, title, instructorid, description, workshopstart, workshopfinish, location As String

        id = workshopIdBox.Text
        title = workshopTitleBox.Text
        instructorid = workshopInstructorUserNameBox.Text
        description = workshopDescriptionBox.Text
        workshopstart = workshopStartBox.Text
        workshopfinish = workshopFinishBox.Text
        location = workshopLocationBox.Text


        SqlDataSource1.InsertParameters("ID").DefaultValue = id
        SqlDataSource1.InsertParameters("TITLE").DefaultValue = title
        SqlDataSource1.InsertParameters("INSTRUCTORID").DefaultValue = instructorid
        SqlDataSource1.InsertParameters("DESCRIPTION").DefaultValue = description
        SqlDataSource1.InsertParameters("WORKSHOPSTART").DefaultValue = workshopstart
        SqlDataSource1.InsertParameters("WORKSHOPFINISH").DefaultValue = workshopfinish
        SqlDataSource1.InsertParameters("LOCATION").DefaultValue = location

        SqlDataSource1.Insert() 


        'back to my workshop manager
        Response.Redirect("ManageWorkshops.aspx")
    End Sub

    Protected Sub backButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles backButton.Click
        Response.Redirect(prevPage)
    End Sub
End Class